<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var str = 'hello string'

    // 字符串也有索引和length
    console.log(str.length) // 12 空格也是有意义的字符

    console.log(str[0]) // h

    // 如果要遍历字符串就用普通for循环
    for (var i = 0; i < str.length; i++) {
      console.log(str[i])
    }

  </script>
</body>
</html>